﻿using System;
using System.Data;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using PolePositionMobileUtilityEntity.Logic;
using PolePositionMobileUtilityGeneral;

namespace PolePositionMobileUtilityEntity.Entities
{
    public class EContact : EBaseLookup
    {
        private EVendor m_vendor;


        public EVendor Vendor
        {
            get { return m_vendor; }
        }

        public EContact()
            :base()
        {
            m_vendor = new EVendor();
            m_TableName = "tb_Users";
            m_TableCollumnId = "UserId";
        }

        public EContact(Int32 id, string name)
            :this()
        {
            Id = id;
            Name = name;
        }
        public EContact(Int32 id, string name, Int32 idVendor)
            : this(id,name)
        {
            m_vendor = new EVendor(idVendor); 
        }

        protected override System.Data.DataTable SelectAll()
        {
            return LVendor.SelectContacts();

        }

        public EContact[] GetAll()
        {
            DataTable _dtContacts = SelectAll();

            EContact[] arr = new EContact[_dtContacts.Rows.Count];
            for (int i = 0; i < _dtContacts.Rows.Count; i++)
            {
                arr[i] = new EContact(ConvertMobileHelper.ToInt32(_dtContacts.Rows[i][m_TableCollumnId]), ConvertMobileHelper.Tostring(_dtContacts.Rows[i][m_TableCollumnName]), ConvertMobileHelper.ToInt32(_dtContacts.Rows[i]["VendorFk"]));
            }
            return arr;
        }
    }
}
